\documentclass[11pt,a4paper, final]{moderncv}

\usepackage{color}
\usepackage{fontspec}
\moderncvtheme{classic}

% the (custom) color which will be used in the cv
\definecolor{color1}{RGB}{1, 52, 64}

% scale the page layout
\usepackage[scale=0.75]{geometry}

% change width of the column with the dates
\setlength{\hintscolumnwidth}{2.5cm} 

% required when changing page layout lengths
\AtBeginDocument{\recomputelengths} 
\usepackage{xunicode}
\usepackage{xltxtra}
\usepackage[utf8]{inputenc}

% german word break/hyphenation rules
\usepackage[ngerman]{babel}

% insert dummy text (used in the letter)
\usepackage{lipsum} 

% used for \begin{comment}...\end{comment}
\usepackage{verbatim} 

% use guilllemets in bibliography
\usepackage[babel,german=guillemets]{csquotes}

\usepackage[
	sorting=none,
	minbibnames=8,
	maxbibnames=9,
	block=space
]{biblatex}

\bibliography{publications}


% get rid of the number-labels ([1], [2], etc.) in front of publications
\defbibenvironment{midbib}
{\list
	{}
	{
		\setlength{\leftmargin}{0mm}
		\setlength{\itemindent}{-\leftmargin}
		\setlength{\itemsep}{\bibitemsep}
		\setlength{\parsep}{\bibparsep}}
	}
	{\endlist}
{\item}


% add [DOI] and [PDF] fields at the end of each publication entry
\DeclareSourcemap{
	\maps[datatype=bibtex]{
		% the bibtex entry 'mydoi' gets mapped to 'usera'
		\map{
			\step[fieldsource=mydoi]
			\step[fieldset=usera, origfieldval]
		}
		% the bibtex entry 'mypdf' gets mapped to 'usera'
		\map{
			\step[fieldsource=mypdf]
			\step[fieldset=userb, origfieldval]
		}
	}
}

% [DOI] entries in publication
\DeclareFieldFormat{usera}{\color{color1}[\href{#1}{\textsc{doi}}]}
\AtEveryBibitem{
	% put [DOI] stuff at the end of a publication entry
	\csappto{blx@bbx@\thefield{entrytype}}{% 
		\iffieldundef{usera}{ 
			% this gets invoked, once nothing is supplied
			% via the mypdf or mydoi value.
			% you could e.g. display a default thing here.
		}{\space\printfield{usera}}}
}

% [PDF] entries in publication
\DeclareFieldFormat{userb}{\color{color1}[\href{#1}{\textsc{pdf}}]}

\AtEveryBibitem{
	% put [DOI] stuff at the end of a publication entry
	\csappto{blx@bbx@\thefield{entrytype}}{\iffieldundef{userb}{}{\printfield{userb}}}
}

\renewcommand*{\mkbibnamegiven}[1]{%
	\ifitemannotation{highlight}
	{\textbf{#1}}
	{#1}}

	\renewcommand*{\mkbibnamefamily}[1]{%
	\ifitemannotation{highlight}
	{\textbf{#1}}
	{#1}
}


% Minion Pro is used as the main font, if you don't
% have it installed uncomment this line or choose another pretty font
\setmainfont[Numbers=OldStyle]{Minion Pro}

% the moderncv package will populate a lot of the pdf meta-information.
% this can be used to change some of these infos.
\AfterPreamble{\hypersetup{
  pdfcreator={XeLaTeX},
  pdftitle={Fictional CV of Isaac Asimov}
}}

% for the icons (telephone, globe). i found the icons provided by the
% fontawesome package prettier than the standard moderncv icons.
\usepackage{fontawesome}

% personal data
\firstname{Isaac}
\familyname{Asimov}
\address{Random St. 21}{9873 New York}

% i use the extrainfo command for additional information, since i 
% want to use custom icons and have finer control over spacing.
\extrainfo{
	\faPhone\hspace{0.3em}+49 137 3717321\\
	{\small\faEnvelope}\hspace{0.3em}isaac@asimov.com\\
	\faGlobe\hspace{0.3em}http://isaac.asimov.com
}

% picture, resized to a height of 84pt
\photo[84pt]{picture/photo}

% spacing before (sub)sections
\newcommand{\spacesection}{\vspace{0.4cm}}
\newcommand{\spacesubsection}{\vspace{0.2cm}}


%===========================
\begin{document}

\maketitle

\section{Personal Data}
\cvline{Name}{Isaac Asimov}
\cvline{Geburtsdatum}{20.12.1919}
\cvline{Geburtsort}{Petrovichi, Russia}

\spacesection
\section{Education}
\cventry{\textsc{1948}}{Ph.D. Chemistry}{University Extension}{New York}{\emph{United States}}{}
\cventry{\textsc{1939--1941}}{M.Sc. Chemistry}{University Extension}{New York}{\emph{United States}}{}
\cventry{\textsc{1935--1939}}{B.Sc. Chemistry}{University Extension}{New York}{\emph{United States}}{}
\cventry{\textsc{1930--1935}}{High School}{Boys High School}{Brooklyn}{\emph{United States}}{}

\spacesection
\section{Experience}
\subsection{Academic Services}
\cventry{\textsc{1958--present}}{Advisor}{Boston University School of Medicine}{}{}{
	Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus
	elit, vestibulum ut, placerat ac, adipiscing vitae, felis. 
}
\cventry{\textsc{1951--1958}}{Advisor}{Boston University School of Medicine}{}{}{
	Pellentesque cursus luctus mauris. Nulla malesuada porttitor diam. 
	Donec felis erat, congue non, volutpat at, tincidunt tristique, libero.
}

\spacesubsection
\subsection{Industry Work Experience}
\cventry{\textsc{1958--present}}{Advisor}{Boston University School of Medicine}{}{}{
	Vivamus viverra fermentum felis. Donec nonummy pellentesque ante.
	Phasellus adipiscing semper elit. Proin fermentum massa ac quam.
}

\newpage
\spacesection
\section{Expertise}
\subsection{Chemistry}
\cvcomputer{Vitae}{Adipiscing, Vitae, Felis}
           {Placerat}{Vitae, Adipiscing, Felis}
\cvcomputer{Consectetuer}{Felis, Adipiscing, Vitae}
           {Donec}{Felis, Erat, Congue non}

\spacesubsection
\subsection{Computer Science}
\cvcomputer{Lugla}{Adipiscing, Vitae, Felis}
           {Tincident}{Tristique, Libero}
\cvcomputer{Eleifend}{Morbi blandit, Ligula}
           {Accumsan}{Nam ipsum, suscipit}

\spacesection
\section{Interests}
\cvline{Adipiscing}{
	Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus
	elit, vestibulum ut, placerat ac, adipiscing vitae, felis. 
}
\cvline{Vestibulum}{
	Maecenas lacinia. Nam ipsum ligula, eleifend at, accumsan nec, suscipit a,
	ipsum. Morbi blandit ligula.
}


\spacesection
\section{Miscellaneous}
\cventry{\textsc{1958--1963}}{Adipiscing Elit}{New York}{}{}{
	Vivamus viverra fermentum felis. Donec nonummy pellentesque ante. Phasellus
	adipiscing semper elit. Pellentesque cursus luctus mauris.
}


\spacesection
\section{Publications}
{\color{color1}\textsc{Acamdemic Writings}}

\nocite{*}
\printbibliography[heading=none, env=midbib, keyword=academic]

\ \\

{\color{color1}\textsc{Fictional Writings}}
\printbibliography[heading=none, env=midbib, keyword=fiction]



%=============================
% this part is a simple cover letter
\clearpage

\recipient{Human Resources}{Some Company Ltd.\\Some Street 123\\12345 Some City} 
\date{\today}
\opening{Dear Sir or Madam,}
\closing{Sincerely yours,}
\enclosure[Attached]{curriculum vit\ae{}}

\makelettertitle

\lipsum[1-3] 

\makeletterclosing


\end{document}
